<template>
	<view>
		<view class="items">
			<navigator :url="'/pages/detail/detail?id='+item.id" v-for="item in items" :key="item.id">
				<view class="item">
					<image :src="item.pic" mode="scaleToFill"></image>
					<view class="item-info">
						<text class="item-name">商品名:{{item.name}}</text>
						<text class="price">商品价格:￥{{item.minPrice}}</text>
					</view>
				</view>
			</navigator>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				items: []
			}
		},
		methods: {
			fetchItems(categoryId) {
				this.$request('/shop/goods/list/v2', {
					method: 'POST',
					data: {
						categoryId
					}
				}).then(res => {
					if (res.code === 0) {
						this.items = res.data.result
					}
				})
			}
		},
		onLoad(options) {
			this.fetchItems(options.cateId);
		}
	}
</script>

<style lang="scss" scoped>
	.item {
		display: flex;
		align-items: center;

		.item-info {
			flex: 1;
		}

		image {
			width: 160rpx;
			height: 160rpx;
		}
	}
</style>